<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <!-- <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item> -->
          <!-- <el-form-item label="状态">
            <el-input v-model="form.status" style="width: 370px;" />
          </el-form-item> -->
          <el-form-item label="类型">
            <el-input v-model="form.type" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="图片">
            <el-input v-model="form.url" style="width: 370px;" />
          </el-form-item>
          <!-- <el-form-item label="识别文字">
            <el-input v-model="form.content" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="解析文档">
            <el-input v-model="form.contentBaike" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="上传ip">
            <el-input v-model="form.ip" style="width: 370px;" />
          </el-form-item> -->
          <!-- <el-form-item label="上传者">
            <el-input v-model="form.operator" style="width: 370px;" />
          </el-form-item> -->
          <!-- <el-form-item label="createdAt">
            <el-input v-model="form.createdAt" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="updatedAt">
            <el-input v-model="form.updatedAt" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="外链">
            <el-input v-model="form.outUrl" style="width: 370px;" />
          </el-form-item> -->
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="id" />
        <!-- <el-table-column prop="status" label="状态" /> -->
        <el-table-column prop="type" label="类型" />
        <el-table-column prop="url" label="图片">
          <div slot-scope="scope">
            <div class="demo-image__preview">
              <el-image style="width: 80px;height: 80px;"
                :src="scope.row.url"
                :zoom-rate="1.2"
                :preview-src-list="[scope.row.url]"
                fit="cover"
              />
            </div>
          </div>
        </el-table-column>
        <!-- <el-table-column prop="content" label="识别文字" />
        <el-table-column prop="contentBaike" label="解析文档" /> -->
        <el-table-column prop="ip" label="上传ip" />
        <el-table-column prop="operator" label="上传者" />
        <!-- <el-table-column prop="createdAt" label="createdAt" />
        <el-table-column prop="updatedAt" label="updatedAt" />
        <el-table-column prop="outUrl" label="外链" /> -->
        <!-- <el-table-column v-if="checkPer(['admin','dccOss:edit','dccOss:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudDccOss from '@/api/dccOss'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, status: null, type: null, url: null, content: null, contentBaike: null, ip: null, operator: null, createdAt: null, updatedAt: null, outUrl: null }
export default {
  name: 'DccOss',
  components: { pagination},
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '毒查查oss相关', url: 'api/dccOss', idField: 'id', sort: 'id,desc', crudMethod: { ...crudDccOss }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'dccOss:add'],
        edit: ['admin', 'dccOss:edit'],
        del: ['admin', 'dccOss:del']
      },
      rules: {
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>
.demo-image__error .image-slot {
  font-size: 30px;
}
.demo-image__error .image-slot .el-icon {
  font-size: 30px;
}
.demo-image__error .el-image {
  width: 100%;
  height: 200px;
}
</style>
